//
//  UIFontExt.swift
//  SeeFM_Swift
//
//  Created by CBCT_MBP on 2021/5/25.
//

import Foundation

extension UIFont {
    static func FuturaBold(_ fontSize: CGFloat) -> UIFont {
        if let font = UIFont.init(name: "Futura-Bold", size: fontSize) {
            return font
        }
        return UIFont.systemFont(ofSize: fontSize, weight: .bold)
    }
    
    static func FuturaMedium(_ fontSize: CGFloat) -> UIFont {
        if let font = UIFont.init(name: "Futura-Medium", size: fontSize) {
            return font
        }
        return UIFont.systemFont(ofSize: fontSize, weight: .medium)
    }
}

extension UIFont {
    
    func withTraits(traits:UIFontDescriptor.SymbolicTraits) -> UIFont {
        let descriptor = fontDescriptor.withSymbolicTraits(traits)
        return UIFont(descriptor: descriptor!, size: 0) //size 0 means keep the size as it is
    }
    
    func bold() -> UIFont {
        return withTraits(traits: .traitBold)
    }
    
    func italic() -> UIFont {
        return withTraits(traits: .traitItalic)
    }
}
